test /** * ============================================================================ * GEORGE MATERIALS - FULL-SITE SEO & CORE WEB VITALS OPTIMIZATION SUITE * ============================================================================ */ function gm_get_seo_matrix() { return array( 7454 => array( 'title' => 'One-Stop Building Materials & Custom Joinery | George', 'desc' => "George Materials is China's premier architectural manufacturer in Foshan, delivering factory-direct joinery, tiles, sanitary ware & turnkey engineering.", 'focus' => 'Building Materials Foshan' ), 7607 => array( 'title' => 'Building Material Divisions & Ateliers | George Materials', 'desc' => 'Explore George Materials manufacturing divisions in Foshan: architectural ceramics, custom cabinetry, thermal-break windows & sanitary ware systems.', 'focus' => 'Building Material Divisions' ), 7719 => array( 'title' => 'Global Architectural Building Portfolios | George Group', 'desc' => 'Discover George Materials global turnkey projects: luxury private villas, five-star hospitality resorts, and commercial developments across 7 continents.', 'focus' => 'Architectural Projects Portfolio' ), 7641 => array( 'title' => 'About George Materials | Foshan Turnkey Manufacturer', 'desc' => 'Founded in Foshan, George Materials is a global architectural manufacturer providing one-stop building solutions and BIM engineering for developers.', 'focus' => 'About George Materials' ), 7893 => array( 'title' => 'Project Engineering & Takeoff Specialists | George Group', 'desc' => 'Meet George Materials senior project directors, BIM coordinators & international BOQ takeoff engineers delivering rapid factory-direct project budgets.', 'focus' => 'Project Engineering Takeoff' ), 7957 => array( 'title' => 'Architectural Journal & Sourcing Guides | George Group', 'desc' => 'In-depth procurement guides, ASTM glazing benchmarks, sintered stone comparisons, and factory takeoff dispatches directly from George Materials Foshan.', 'focus' => 'Architectural Sourcing Guides' ), 7717 => array( 'title' => 'Contact George Materials | Request Factory BOQ Quote', 'desc' => 'Contact George Materials headquarters in Foshan, China. Submit your architectural CAD drawings for rapid BOQ takeoff, 3D proposals, and direct quotes.', 'focus' => 'Contact George Materials Quote' ), 8181 => array( 'title' => 'Privacy Policy & Commercial Data Security | George Group', 'desc' => 'Read George Materials international privacy policy, architectural drawings confidentiality commitment, and GDPR commercial data compliance protocols.', 'focus' => 'Privacy Policy Commercial Data' ), 8771 => array( 'title' => 'Forward Deployed Engineering: AI BOQ Estimation | George', 'desc' => 'How George Materials Ceramic Division built an internal AI takeoff engine, slashing architectural BOQ quotation turnaround from 48 hours to under 2 hours.', 'focus' => 'Forward Deployed Engineering BOQ' ), 8751 => array( 'title' => "The Architect's Guide to Luxury Cabinet Hardware | George", 'desc' => 'Hardware accounts for 10%–15% of your millwork budget, yet defines 80% of client satisfaction. How Blum, Hettich, GRASS & Salice compare for estates.', 'focus' => 'Luxury Cabinet Hardware Guide' ), 8750 => array( 'title' => 'Importing Commercial Cabinetry: US & EU Compliance Guide', 'desc' => 'A master guide to global emissions standards (CARB P2, TSCA VI, ENF) and ISPM 15 packaging rules to eliminate customs delays for commercial projects.', 'focus' => 'Importing Commercial Cabinetry Compliance' ) ); } // 1. Filter Frontend Document Title add_filter('pre_get_document_title', function($title) { $matrix = gm_get_seo_matrix(); $id = get_queried_object_id(); if (isset($matrix[$id]['title'])) { return $matrix[$id]['title']; } return $title; }, 9999); add_filter('rank_math/frontend/title', function($title) { $matrix = gm_get_seo_matrix(); $id = get_queried_object_id(); if (isset($matrix[$id]['title'])) { return $matrix[$id]['title']; } return $title; }, 9999); // 2. Filter Frontend Meta Description add_filter('rank_math/frontend/description', function($desc) { $matrix = gm_get_seo_matrix(); $id = get_queried_object_id(); if (isset($matrix[$id]['desc'])) { return $matrix[$id]['desc']; } return $desc; }, 9999); // 3. Filter Social OpenGraph & Twitter add_filter('rank_math/opengraph/facebook/title', function($t) { $matrix = gm_get_seo_matrix(); $id = get_queried_object_id(); return isset($matrix[$id]['title']) ? $matrix[$id]['title'] : $t; }, 9999); add_filter('rank_math/opengraph/facebook/description', function($d) { $matrix = gm_get_seo_matrix(); $id = get_queried_object_id(); return isset($matrix[$id]['desc']) ? $matrix[$id]['desc'] : $d; }, 9999); add_filter('rank_math/opengraph/twitter/title', function($t) { $matrix = gm_get_seo_matrix(); $id = get_queried_object_id(); return isset($matrix[$id]['title']) ? $matrix[$id]['title'] : $t; }, 9999); add_filter('rank_math/opengraph/twitter/description', function($d) { $matrix = gm_get_seo_matrix(); $id = get_queried_object_id(); return isset($matrix[$id]['desc']) ? $matrix[$id]['desc'] : $d; }, 9999); // 4. Performance: Dual-Breakpoint LCP Preload, Non-Blocking Fonts & Deferred Scripts add_action('wp_head', function() { $id = get_queried_object_id(); echo '' . " "; echo '' . " "; if ($id == 7454 || is_front_page()) { echo '' . " "; echo '' . " "; echo '' . " "; } }, 1); // Non-blocking Google Fonts add_filter('style_loader_tag', function($html, $handle, $href, $media) { if (is_admin()) return $html; if (strpos($handle, 'google-fonts') !== false || strpos($href, 'fonts.googleapis.com') !== false) { return '' . " " . '' . " "; } return $html; }, 10, 4); // Defer Core Frontend Scripts add_filter('script_loader_tag', function($tag, $handle, $src) { if (is_admin()) return $tag; if (in_array($handle, array('jquery-core', 'jquery-migrate', 'wp-hooks', 'wp-i18n'))) { if (strpos($tag, ' defer') === false) { return str_replace(' src=', ' defer src=', $tag); } } return $tag; }, 10, 3); // 5. Universal Image Alt Fallback & Elementor Alt Completer add_filter('wp_get_attachment_image_attributes', function($attr, $attachment) { if (empty($attr['alt'])) { $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); if (empty($alt)) { $title = get_the_title($attachment->ID); $clean = preg_replace('/[_\-]+|\.(webp|png|jpe?g)$/i', ' ', $title); $clean = trim(preg_replace('/\s+/', ' ', $clean)); $attr['alt'] = esc_attr('George Materials Architectural ' . ucwords($clean)); } else { $attr['alt'] = esc_attr($alt); } } return $attr; }, 10, 2); add_filter('elementor/widget/render_content', function($content, $widget) { if ($widget->get_name() === 'image') { if (strpos($content, 'alt=""') !== false || strpos($content, "alt=''") !== false || !preg_match('/alt=[\"\'][^\"\']+[\"\']/', $content)) { if (preg_match('/src=[\"\']([^\"\']+)[\"\']/', $content, $m)) { $src = $m[1]; $filename = basename(urldecode(parse_url($src, PHP_URL_PATH))); $clean = preg_replace('/[_\-]+|\.(webp|png|jpe?g)$/i', ' ', $filename); $clean = trim(preg_replace('/\s+/', ' ', $clean)); $alt_text = 'George Materials Architectural ' . ucwords($clean); if (strpos($content, 'alt=""') !== false) { $content = str_replace('alt=""', 'alt="' . esc_attr($alt_text) . '"', $content); } elseif (strpos($content, "alt=''") !== false) { $content = str_replace("alt=''", 'alt="' . esc_attr($alt_text) . '"', $content); } else { $content = str_replace('' . esc_attr($alt_text) . ' $data) { update_post_meta($post_id, 'rank_math_title', $data['title']); update_post_meta($post_id, 'rank_math_description', $data['desc']); update_post_meta($post_id, 'rank_math_focus_keyword', $data['focus']); $results[] = "Post ID {$post_id} updated: Title (" . strlen($data['title']) . " chars), Desc (" . strlen($data['desc']) . " chars)"; } // Update Media Alt Texts in Bulk $media_alts = array( 7832 => 'George Materials 2F showroom architectural ceramic and large-format porcelain slabs', 7834 => 'George Materials 2F showroom luxury sanitary ware freestanding tubs and bathroom vanities', 7835 => 'George Materials 11F showroom thermal-break aluminum windows and slim sliding door systems', 7940 => 'George Materials 4F showroom custom cabinetry whole-house joinery and walk-in dressing suites', 7840 => 'Architectural sintered stone and natural bookmatched marble exhibition', 7833 => 'Bespoke luxury commercial furniture and custom interior fit-out collection', 7836 => 'Architectural acoustic wood wall panelling and interior cladding systems', 7837 => 'High-end aluminum framed glass doors and architectural metal partitions', 7838 => 'Integrated architectural kitchen appliances and engineering solutions', 7839 => 'George Materials turnkey architectural procurement and supply chain management', 7841 => 'Contemporary architectural lighting and luxury pendant chandelier installations', 7842 => 'Architectural lighting fixtures and ambiance illumination systems', 8487 => 'Architectural 3D BIM design and VR spatial modeling presentation', 8328 => 'Architectural solid wood flooring and custom floating staircase millwork', 8197 => 'Architectural hardwood flooring herringbone and chevron pattern millwork', 8183 => 'George Materials Foshan architectural travertine pavilion and headquarters facade', 7977 => 'George Materials minimalist travertine architectural pavilion and water feature', 8151 => 'George Materials architectural building showcase on Nasdaq Times Square billboard', 8139 => 'Luxury private palace villa project exterior and architectural glazing in Nigeria', 8138 => 'Five-star commercial hospitality resort building materials project in Cameroon', 8137 => 'Contemporary residential villa facade and panoramic slim sliding doors in Australia', 8136 => 'Modern architectural villa exterior and thermal-break aluminum facade in Australia', 8135 => 'Bespoke modern villa stone facade and exterior joinery in Oman', 8134 => 'Commercial architectural building complex and curtain wall facade in Pakistan', 8133 => 'Luxury modern villa living interior and architectural millwork in Geneva Switzerland', 8132 => 'Oceanfront villa infinity swimming pool and architectural sintered stone patio in France', 8129 => 'Luxury hillside residential estate and minimalist glazing systems in Los Angeles USA', 8128 => 'Bespoke luxury kitchen cabinetry and sintered stone island fit-out', 8127 => 'Contemporary open-plan villa living room with custom architectural woodwork', 8126 => 'Luxury residential villa living room interior and architectural wall cladding', 8770 => 'Forward deployed engineer conducting AI BOQ estimation for architectural ceramics at George Materials Foshan', 8747 => 'Architectural luxury cabinetry hardware hinges and lift systems guide', 8746 => 'Commercial cabinetry packaging and environmental compliance standards documentation', 7682 => 'George Materials 20000 square meter headquarters and showroom exterior in Foshan', 7724 => 'George Materials architectural building materials headquarters in Foshan China', 7738 => 'George Materials corporate office and showroom facility Chancheng District Foshan', 7725 => 'George Materials executive coffee lounge and client consultation suite', 7739 => 'George Materials VIP architectural design lounge and hospitality bar' ); $media_count = 0; foreach ($media_alts as $mid => $alt_text) { update_post_meta($mid, '_wp_attachment_image_alt', $alt_text); $media_count++; } if (function_exists('wp_cache_flush')) { wp_cache_flush(); } do_action('litespeed_purge_all'); header('Content-Type: text/plain; charset=utf-8'); echo "=== GEORGE MATERIALS SEO & ALT SYNC COMPLETE ===\\n\\n"; echo implode("\\n", $results) . "\\n\\n"; echo "Total media attachments updated with authentic alt text: {$media_count}\\n"; echo "LiteSpeed cache purged successfully.\\n"; exit; } });